<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="x-ua-compatible"    content="ie=edge">
        <title>首页</title>
        <script src="js/mui.min.js"></script>
        <script type="text/javascript" charset="utf-8">
            mui.init();
        </script>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <link rel="stylesheet" type="text/css" href="../public/swiper-3.4.2.min.css">
        <link rel="stylesheet" type="text/css" href="../public_css/public_header.css">

        <link rel="stylesheet" href="normalize.css">
        <link rel="stylesheet" href="homepage.css">
        <script src="../public/jquery.min.js"></script>

        <script src="../public/layer.js"></script>
        <script src="../public/swiper-3.4.2.min.js"></script>
        <script src="picturefill.js"></script>
         <!--热更新版本号-->
        <script src="../public/mui.js"></script>
        <style>
            .swiper-container {
                height: 13rem;
            }

            .carousel_pic{
                height: 100%;
            }

        </style>
    </head>
    <body>
        <header class="public_header">

            <div class="searchBox clearfix">
                <form action="" class="search_form">
                    <input type="text"  class='search_one' placeholder="正在进行减免活动" />
                    <img src="search.png" class="search_two"/>
                </form>
            </div>

        </header>

        <!-- <div>新的</div>
<button onclick="upgrade_app_wgt()">当前版本<span id="version_id"></span></button>-->

        <!-- 	<div class="city clearfix">
<select name="city_name" class="city_name">
<option>成都</option>
<option>重庆</option>
<option>西安</option>
</select>
<div class="estop_arrow"></div>
</div> -->
        <section>
            <div class="swiper-container ">
                <div class="swiper-wrapper">

                </div>

            </div>
            <ul class="nav_list">

                <li class="nav_list_num1">
                    <img src="img/free-drive.png" alt="">
                </li>
                <li onclick="window.location.href='../NeedToKnow/shunt.html'">
                    <img src="img/knows_before_drive.png" alt="">
                </li>
                <li class="nav_list_num3">
                    <img src="img/apply_hurry.png" alt="">
                </li>
                <li class="nav_list_num4">
                    <img src="img/study_now.png" alt="">
                </li>
            </ul>

            <div class="order_no">
                <img src="bear-bird.png" alt="">

            </div>
        </section>
        <footer style="margin-top: 0.1rem;">
            <ul class="footer_list">
                <li class="footer_list_num1">
                    <img src="study_drive_on.png" alt="学车">
                </li>
                <li class="footer_list_num2"  onclick="window.location.href='../studentorder/oder.html'">
                    <img src="oderForm_off.png" alt="订单">
                </li>
                <li  onclick="window.location.href='../lianti/index.html'" class="footer_list_num3">
                    <img src="practice_off.png" alt="练题">
                </li>
                <li class="footer_list_num4" onclick="window.location.href='../my/me.html'">
                    <img src="me_off.png" alt="我">
                </li>
            </ul>
        </footer>

        <script type="text/javascript">

            $(".search_one").click(function(){
                layer.msg("内测中");
            });

            $(function () {
                $.ajax({
                    url: "https://newapp.icandrive.cn/api/news.php",
                    type:'post',
                    dataType:'json',
                    data:{},
                    success: function (data) {

                        $(data).each(function (){


                            $('.swiper-wrapper').append('<div class="swiper-slide"  onclick="jump('+"'"+this.content+"'"+')"> ' +
                                                        '<a class="carousel_link" ><img class="carousel_pic" src="https://newapp.icandrive.cn/tp/Uploads/'
                                                        +this.img+'" alt="error"><div class="contents clearfix"><div class="news_1">' +
                                                        '<h3 class="news_title clearfix">'+this.title+'</h3><article class="news_content clearfix"></article></div><div class="news_2"><h4 class="news_source clearfix">'+this.source+'' +
                                                        '</h4><article class="news_time clearfix">'+this.create_time+'</article></div></div></a></div>');
                        });



                        var swiper = new Swiper('.swiper-container', {
                            pagination: '.swiper-pagination',
                            paginationClickable: true,
                            parallax: true,
                            speed: 300,
                            autoplay:2000,
                            loop:true,
                            grabCursor:false,
                         /*   resistanceRatio: 0，*/
                            resistanceRatio : 0.9,
                        });

                    }
                });
            });

            function jump(res){
                localStorage.iframe_url = res;
                window.location.href = "jump.html";

            }

            $(".nav_list_num1").click(function() {
                var token = localStorage.phone;
                $.ajax({
                    url: "https://newapp.icandrive.cn/api/index.php",
                    type: 'post',
                    data: {token: token},
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == 200) {
                            $.ajax({
                                url: "https://newapp.icandrive.cn/api/realName.php",
                                type: 'post',
                                data: {token: token},
                                dataType: 'json',
                                success: function (data) {
                                    if (data.status == 200) {
                                        window.location.href = "../info/drive_information.html";
                                    }
                                    if (data.status == 250) {
                                        layer.msg("请重新登录");
                                        setInterval(function () {
                                            window.location.href = "../login/log_in.html";
                                        }, 2000)
                                    }
                                    if (data.status == 400) {
                                        layer.msg('请先实名认证');
                                        setInterval(function () {
                                            window.location.href = "../info/information.html"
                                        }, 2000)
                                    }
                                },
                                error: function () {
                                    layer.msg('系统维护中',function(){
                                        history.go(0)
                                    },1000);
                                }
                            });

                        }
                        if (data.status == 400) {
                            layer.msg('您已申请过免费试驾');
                        }

                    },
                    error: function () {
                        layer.msg('系统维护中',function(){
                            history.go(0)
                        },1000);
                    }
                });
            });
            $(".nav_list_num3").click(function() {
                var token = localStorage.phone;
                $.ajax({
                    url: "https://newapp.icandrive.cn/api/realName.php",
                    type: 'post',
                    data: {token: token},
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == 200) {
                            window.location.href = "../schoolList/schoolList.html";
                        }
                        if (data.status == 250) {
                            layer.msg("请重新登录");
                            setInterval(function () {
                                window.location.href = "../login/log_in.html";
                            }, 2000)
                        }
                        if (data.status == 400) {
                            layer.msg('请先实名认证');
                            setInterval(function () {
                                window.location.href = "../info/information.html"
                            }, 2000)
                        }

                    },
                    error: function () {
                        layer.msg('系统维护中',function(){
                            history.go(0)
                        },1000);
                    }
                });
            });

            $(".nav_list_num4").click(function() {
                var token = localStorage.phone;
                $.ajax({
                    url: "https://newapp.icandrive.cn/api/realName.php",
                    type: 'post',
                    data: {token: token},
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == 200) {
                            window.location.href = "../date_teacher/arrange_teaching.html";
                        }
                        if (data.status == 250) {
                            layer.msg("请重新登录");
                            setInterval(function () {
                                window.location.href = "../login/log_in.html";
                            }, 2000)
                        }
                        if (data.status == 400) {
                            layer.msg('请先实名认证');
                            setInterval(function () {
                                window.location.href = "../info/information.html"
                            }, 2000)
                        }

                    },
                    error: function () {
                        layer.msg('系统维护中',function(){
                            history.go(0)
                        },1000);
                    }
                });
            });


        </script>



        <script>document.addEventListener("plusready", function() {
                // 注册返回按键事件
                plus.key.addEventListener('backbutton', function() {
                    // 事件处理
                    plus.nativeUI.confirm("退出程序？", function(event) {
                        if (event.index) {
                            plus.runtime.quit();
                        }
                    }, null, ["取消", "确定"]);
                }, false);
            });
        </script>

        <!--热更新版本号-->
        <script src="../public/mui.js"></script>
        <script>
            mui.init();
            var _config = {url : 'https://newapp.icandrive.cn/api/'}
            var checkUrl= _config.url + "edition.php";
            //需要传递当前的版本
            function checkUpdate( wgtVer ){

//                plus.nativeUI.showWaiting("检测更新...");
                mui.ajax( checkUrl , { dataType : "json", type : 'POST',
                                      data : {ver : wgtVer},
                                      success : function(json){
                                          plus.nativeUI.closeWaiting();
                                          if( parseInt(json.code) ==1 ){
                                              //可以升级
                                              plus.nativeUI.confirm("检查到当前版本有最新更新，下载升级？",
                                                                    function(event){
                                                  if(event.index ==0){

                                                      downWgt(json.url); //下载更新版的地址
                                                  }
                                              } ,'系统消息',['马上升级','下次再说']);
                                          } else{
//                                              plus.nativeUI.toast("无新版本可更新！");
                                          }
                                      },
                                      error : function(xhr, error){
                                          plus.nativeUI.closeWaiting();
                                          plus.nativeUI.toast('检测更新失败！') ;
                                      }
                                     }) ;
            }
            // 下载wgt文件

            function downWgt(wgtUrl){
                plus.nativeUI.showWaiting("下载更新文件...");
                plus.downloader.createDownload( wgtUrl, {filename:"_doc/update/"}, function(d,status){
                    if ( status == 200 ) {
                        //console.log("下载wgt成功："+d.filename);
                        installWgt(d.filename); // 安装wgt包
                    } else {
                        //console.log("下载wgt失败！");
                        plus.nativeUI.alert("下载更新失败！");
                    }
                    plus.nativeUI.closeWaiting();
                }).start();
            }
            // 更新应用资源
            function installWgt(path){
                plus.nativeUI.showWaiting("安装更新文件...");
                plus.runtime.install(path,{},function(){
                    plus.nativeUI.closeWaiting();
                    plus.nativeUI.alert("应用资源更新完成！",function(){
                        plus.runtime.restart();
                    });
                },function(e){
                    plus.nativeUI.closeWaiting();
                    plus.nativeUI.alert("安装更新文件失败["+e.code+"]："+e.message);
                });
            }

        </script>
        <script type="text/javascript">
            //在页面中初始化plus插件
            mui.init();
            mui.plusReady(function(){
                plus.runtime.getProperty(plus.runtime.appid,function(inf){

                    checkUpdate(inf.version)

                });
            });
            //检测升级
            function  upgrade_app_wgt(){
                plus.runtime.getProperty(plus.runtime.appid,function(inf){
                    checkUpdate( inf.version);
                    console.log(inf.version)
                    sessionStorage.setItem('upgrade','1');
                });
            }
        </script>
    </body>
</html>
